package com.kxc.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**错误及及警告、自定义日志记录工具类
 * @author 崔耀强
 * @Date 2019-1-2
 * @version 1.0.0
 */
public class LogUtil {

	private LogUtil() {}  
	private static final Logger logger = LoggerFactory.getLogger(LogUtil.class);  
	private static Logger mqInfoLogger = LoggerFactory.getLogger("mqInfo");
	/**
	 * 警告信息记录方法
	 * @param warningMsg警告信息
	 */
	public static void recordWarnMsg(String warningMsg){

		logger.warn(warningMsg);
	}
	/**
	 * 错误信息记录方法
	 * @param e 异常类对象
	 */
	public static void recordErrorMsg(Exception e){

		StringBuffer sbf=new StringBuffer(e.getMessage());
		StackTraceElement[] stackTrace = e.getStackTrace();
		for(StackTraceElement element:stackTrace){
			sbf.append("\r\n           "+element);
		}
		logger.error(sbf.toString()); 
	}
	/**自定义信息记录方法
	 * @param string
	 */
	public static void recordInfoMsg(String info) {
		
		mqInfoLogger.info(info);
	}
}